﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TP_EDA_5847
{
    class No
    {
        public No parent, left, right;
        public List<int> value;

        /// <summary>
        /// Contructor of nodes
        /// </summary>
        /// <param name="value">the coordenades of the point</param>
        public No(List<int> value)
        {
            this.value = value;

            parent = null;
            left = null;
            right = null;
        }

        /// <summary>
        /// Clear the point
        /// </summary>
        public void clean()
        {
            this.parent = null;
            this.left = null;
            this.right = null;
        }

        /// <summary>
        /// returnthe sting to print
        /// </summary>
        /// <returns> the string with all the information to print</returns>
        public string toString()
        {
            string str = "";
            try
            {
                int x;
                for (x = 0; x <= value.Count - 2; x++)
                {
                    str += value[x] + " - ";
                }
                str += value[value.Count - 1];
                str += "(";
            }
            catch
            {
                str = "Null" + "(";
            }
            if (parent == null)
            {
                str += "Null" + ", ";
            }
            else
            {
                int x;
                for (x = 0; x <= parent.value.Count - 2; x++)
                {
                    str += parent.value[x] + " - ";
                }
                str += parent.value[parent.value.Count - 1];
                str += ", ";
            }

            if (left == null)
            {
                str += "Null" + ", ";
            }
            else
            {
                int x;
                for (x = 0; x <= left.value.Count - 2; x++)
                {
                    str += left.value[x] + " - ";
                }
                str += left.value[left.value.Count - 1];
                str += ", ";
            }

            if (right == null)
            {
                str += "Null" + ")";
            }
            else
            {
                int x;
                for (x = 0; x <= right.value.Count - 2; x++)
                {
                    str += right.value[x] + " - ";
                }
                str += right.value[right.value.Count - 1];
                str += ")";
            }
            return str;
        }
    }
}
